package org.leon.framework;

import java.util.HashMap;
import java.util.Map;

public class Mapper {

    private Map<String, MappedHost> hostMap = new HashMap<>();

    public Mapper() {
    }

    public void init() throws Exception {
        if (hostMap.size() == 0) {
            throw new Exception("配置文件错误，没有有效 host");
        }
        for (String key : hostMap.keySet()) {
            hostMap.get(key).init();
        }
    }

    public MappedHost getMappedHost(String hostName) {
        return hostMap.get(hostName);
    }

    public Map<String, MappedHost> getHostMap() {
        return hostMap;
    }
}
